<template>
  <div></div>
</template>
<script setup>
import {onBeforeUnmount} from "vue";
import {useRoute} from "vue-router";
import { features } from "./../setting/features/index";

const route = useRoute();

const {code} = route.query;

let searchValue = "";
window.rubick?.setExpendHeight(60);
window.rubick?.setSubInput(({ text }) => {
  searchValue = text;
}, "回车搜索");

const onKeydownAction = (e) => {
  if (e.code === "Enter") {
    window.rubick.shellOpenExternal(features[code].desc.replace(/\{[^]*\}/g, searchValue))
  }
};

window.addEventListener("keydown", onKeydownAction);

onBeforeUnmount(() => {
  window.removeEventListener("keydown", onKeydownAction);
});

</script>
